﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Stamp_For_Africa_Version_2.Models;
using Stamp_For_Africa_Version_2.Repositories;

namespace Stamp_For_Africa_Version_2.Controllers
{
  public class CatalogueController : Controller
  {
    CatalogueRepository catalogueRepository = new CatalogueRepository();
    //
    // GET: /Catalogue/

    public ActionResult Index()
    {
      List<Catalogue> entries = catalogueRepository.FindAllCatalogues().ToList();
      return View(entries);
    }

    public ActionResult Create()
    {
      return View();
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(Catalogue catalogue)
    {
      Catalogue nCatalogue = new Catalogue();
      nCatalogue = catalogue;
      nCatalogue.Id = Guid.NewGuid();
      catalogueRepository.Add(nCatalogue);
      return RedirectToAction("Index");
    }

    public ActionResult Edit(Guid id)
    {
      Catalogue catalogue = catalogueRepository.GetCatalogue(id);
      return View(catalogue);
    }

    public ActionResult Delete(Guid id)
    {
      Catalogue catalogue = catalogueRepository.GetCatalogue(id);
      catalogueRepository.Delete(catalogue);
      return RedirectToAction("Index");
    }
  }
}
